﻿using System.Web.Mvc;
using YawetagDemo.WebUI.Services;
using YawetagLib.System.Facade.Services;
using YawetagLib.System.Web.Controllers;

namespace YawetagDemo.WebUI.Controllers
{
    public class CoreController : BaseController
    {
        public CoreController(IFacadeFactory facadeFactory) 
            : base(facadeFactory)
        {
        }

        [ActionName("home")]
        [HttpGet]
        public ViewResult Home()
        {
            return View();
        }

        [ActionName("do-work")]
        [HttpGet]
        public ViewResult DoWork()
        {
            return View("work");
        }

        [ActionName("do-basic-retrieval")]
        [HttpGet]
        public ViewResult DoBasicRetrieval()
        {
            ViewBag.Artists = FacadeFactory.Get<Facade>().GetArtistModels();

            return View("basic-retrieval");
        }

        [ActionName("do-callback-operations")]
        [HttpGet]
        public ViewResult DoCallbackOperations()
        {
            FacadeFactory.Get<Facade>().LogArtistsOntoServer();

            return View("callback-operations");
        }

        [ActionName("do-complex-retrieval")]
        [HttpGet]
        public ViewResult DoComplexRetrieval()
        {
            ViewBag.Top10P1AlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels(string.Empty, string.Empty, 0, 5);
            ViewBag.Top10P2AlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels(string.Empty, string.Empty, 5, 5);
            ViewBag.PJTop3AlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels("Pearl Jam", string.Empty, 0, 3);
            ViewBag.Bottom5AlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels(string.Empty, "Stars asc", 0, 5);

            return View("complex-retrieval");
        }

        [ActionName("do-crud-operations")]
        [HttpGet]
        public ViewResult DoCRUDOperations()
        {
            FacadeFactory.Get<Facade>().CreateEntities();
            ViewBag.Top3DCDAlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels("Dead Can Dance", string.Empty, 0, 3);
            FacadeFactory.Get<Facade>().UpdateEntities();
            ViewBag.Top3DCDAgainAlbumRankingItems = FacadeFactory.Get<Facade>().GetAlbumRankingItemModels("Dead Can Dance", string.Empty, 0, 3);
            ViewBag.LisaAndBrendanArtists = FacadeFactory.Get<Facade>().GetLisaAndBrendanArtistModels();
            FacadeFactory.Get<Facade>().DeleteEntities();

            return View("crud-operations");
        }
    }
}
